// 自动生成模板Order
package model

import (
	"time"

	"server/global"
)

// 订单 结构体  Order
type Order struct {
	global.GVA_MODEL
	UserID     uint          `json:"userID" gorm:"column:user_id;comment:购买者ID;"`
	TotalPrice uint          `json:"totalPrice" gorm:"column:total_price;comment:订单价格（分）;"`
	Express    string        `json:"express" gorm:"column:express;comment:快递单号;"`
	Status     string        `json:"status" gorm:"column:status;comment:订单状态;"`
	Detail     []OrderDetail `json:"detail" gorm:"foreignKey:OrderID;references:ID;"`
	PayOrderID string        `json:"payOrderID" gorm:"column:pay_order_id;comment:支付订单ID;"`
	Mobile     string        `json:"mobile" gorm:"column:mobile;comment:收件人电话;"`
	Name       string        `json:"name" gorm:"column:name;comment:收件人姓名;"`
	Province   string        `json:"province" gorm:"column:province;comment:收件省份;"`
	City       string        `json:"city" gorm:"column:city;comment:收件城市;"`
	Area       string        `json:"area" gorm:"column:area;comment:收件区;"`
	Street     string        `json:"street" gorm:"column:street;comment:收件详细地址;"`
	CloseTime  time.Time     `json:"closeTime" gorm:"column:close_time;comment:关闭时间;"`
	Comment    *Comment      `json:"comment" gorm:"->;foreignKey:OrderID;references:ID;"`
}

// TableName 获取自定义表名
func (Order) TableName() string {
	return "shop_order"
}

// 订单详情 结构体 OrderDetail
//
//	type OrderDetail struct {
//		global.GVA_MODEL
//		OrderID   uint `json:"orderID" form:"orderID" gorm:"column:order_id;comment:订单ID;"`       //订单ID
//		GoodID    uint `json:"goodID" form:"goodID" gorm:"column:good_id;comment:商品ID;"`          //商品ID
//		SKUID     uint `json:"skuID" form:"skuID" gorm:"column:sku_id;comment:skuID;"`            //skuID
//		Quantity  uint `json:"quantity" form:"quantity" gorm:"column:quantity;comment:数量;"`       //数量
//		Price     uint `json:"price" form:"price" gorm:"column:price;comment:商品单价;"`              //商品单价
//		IsComment bool `json:"isComment" form:"isComment" gorm:"column:is_comment;comment:是否评论;"` //是否评论
//	}
type OrderDetail struct {
	global.GVA_MODEL
	OrderID   uint `json:"orderID" form:"orderID" gorm:"column:order_id;comment:订单ID;"` //订单ID
	GoodID    uint `json:"goodID" form:"goodID" gorm:"column:good_id;comment:商品ID;"`    //商品ID
	Good      Good `json:"good" gorm:"foreignKey:GoodID;references:ID"`
	SKUID     uint `json:"skuID" form:"skuID" gorm:"column:sku_id;comment:skuID;"` //skuID
	SKU       Sku  `json:"sku" gorm:"foreignKey:SKUID;references:ID"`
	Quantity  uint `json:"quantity" form:"quantity" gorm:"column:quantity;comment:数量;"`       //数量
	Price     uint `json:"price" form:"price" gorm:"column:price;comment:商品单价;"`              //商品单价
	IsComment bool `json:"isComment" form:"isComment" gorm:"column:is_comment;comment:是否评论;"` //是否评论
}

// TableName 订单详情 OrderDetail自定义表名 shop_order_detail
func (OrderDetail) TableName() string {
	return "shop_order_detail"
}

// OrderRes 订单响应结构体
// type OrderRes struct {
// 	Order
// 	Detail []OrderDetail `json:"detail" gorm:"foreignKey:OrderID;references:ID"` //订单详情

// }

// OrderCommentRes 订单及评论响应结构体
// type OrderCommentRes struct {
// 	Order
// 	Detail  OrderDetail `json:"detail" gorm:"foreignKey:OrderID;references:ID"` //订单详情
// 	Comment Comment     `json:"comment" gorm:"->;foreignKey:OrderID;references:ID"`
// }

// type OrderDetailRes struct {
// 	global.GVA_MODEL
// 	OrderID   uint `json:"orderID" form:"orderID" gorm:"column:order_id;comment:订单ID;"` //订单ID
// 	GoodID    uint `json:"goodID" form:"goodID" gorm:"column:good_id;comment:商品ID;"`    //商品ID
// 	Good      Good `json:"good" gorm:"foreignKey:GoodID;references:ID"`
// 	SKUID     uint `json:"skuID" form:"skuID" gorm:"column:sku_id;comment:skuID;"` //skuID
// 	SKU       Sku  `json:"sku" gorm:"foreignKey:SKUID;references:ID"`
// 	Quantity  uint `json:"quantity" form:"quantity" gorm:"column:quantity;comment:数量;"`       //数量
// 	Price     uint `json:"price" form:"price" gorm:"column:price;comment:商品单价;"`              //商品单价
// 	IsComment bool `json:"isComment" form:"isComment" gorm:"column:is_comment;comment:是否评论;"` //是否评论
// }

// func (OrderDetailRes) TableName() string {
// 	return "shop_order_detail"
// }
